package 课堂;

/**
 * Created By  醉美柳舞之众星捧月
 *
 * @author song
 * @date 2017/11/10 17:12
 */
public class MyContainer {
    Object[] items = new Object[2];
    int size;

    public Iterator iterator() {
        return new MyContainerIterator(this);
    }

    public void add(Object object) {
        items[size] = object;
        size++;

    }

    public static void main(String[] args) {
        MyContainer v = new MyContainer();
        v.add("3");
        v.add("2");
        System.out.println("Container contents: ");
        Iterator itr = v.iterator();
        while (itr.hasnext()) {
            System.out.println(itr.next());
        }
    }
}
